package com.msg.xml;

/*
 * This class provide some basic functions for manipulating or accessing the price code table
 * 1. Getting ticket Id given with a ticket level name
 * 2. Creating the request for 4 primary keys in price code table
 * 
 */
public class PriceCode_Utility {
	
	/**
	 * Getting ticket id from price code table given a specific ticket level name
	 * @param ticketLv : the ticket level name
	 * @return : ticket ID
	 */
	public static String getTicketID(String ticketLv) {
		DBHandler DBhandler = DBHandler.getInstance();
		DBRequest request = new DBRequest();
		request.resultCol.add("Ticket_Level_Id");
		request.entries.add("Ticket_Level_Name");
		request.data.add(ticketLv);
		return DBhandler.getData("Ticket_Level", request).get(0);
	}
	
	/**
	 * Creating a request with 4 primary keys included
	 * @param ticketLvId : ticket level id
	 * @return : a default request with 4 primary keys
	 */
	public static DBRequest bindPrimaryKeys(String ticketLvId, String resultColumn, String eventId,
																					String ticketTypeId, String priceLvId) {
		DBRequest request = new DBRequest();
		request.resultCol.add(resultColumn);
		
		request.entries.add("Event_Id");
		request.entries.add("Ticket_Type_Id");
		request.entries.add("Price_Level_Id");
		request.entries.add("Ticket_Level_Id");
		
		request.data.add(eventId);
		request.data.add(ticketTypeId);
		request.data.add(priceLvId);
		request.data.add(ticketLvId);
		
		return request;
	}
}
